<?php

/** 
 * @author yusaint
 * 
 */
class User_Model extends PfinalModelAbstract {
	// TODO - Insert your code here
	public function getById($id){
		$selector = $this->select();
		$feature = $this->select();
		$selector
			->from(array('hm_user','a'),array('userid','name','appid'))
			->where('userid=?',$id)
			->where('appid IN(?)',array(1,2,3))
			->limit(0,10);
		$feature
			->from(array('hm_user_feature','b'))
			->where('id=?',$id)
			->orWhere('appid=?',4);
		
		$config = $this->select();
		
		$config
			->from(array('hm_user_config','c'),array('max_site_num'))
			->where('site_num>?',100);
		
		$chain = $this->beginQuery()
					  ->start($selector)
					  ->leftJoin($feature,'a.userid=b.id')
					  ->leftJoin($config,'a.userid=c.id')
					  ->limit(0,100)
					  ->orderBy('appid','desc');
		return $this->query($chain);
	}
}

?>